{% extends 'home_page/base_index.html' %}
{% load static %}

{% block show_body %}
    <section class="section">
        <div class="card">
            <div class="card-header">面试预约表数据</div>
            <div class="card-body">
                <div class="dataTable-wrapper dataTable-loading no-footer sortable searchable fixed-columns">
                    <div class="dataTable-container">
                        <table class="table table-striped dataTable-table" id="table1">
                            <thead>
                            <tr>
                                <th data-sortable="" style="width: 20%;"><a href="#" class="dataTable-sorter">面试预约ID</a></th>
                                <th data-sortable="" style="width: 20%;"><a href="#" class="dataTable-sorter">岗位</a></th>
                                <th data-sortable="" style="width: 20%;"><a href="#" class="dataTable-sorter">学生姓名</a></th>
                                <th data-sortable="" style="width: 20%;"><a href="#" class="dataTable-sorter">预约状态</a></th>
                                <th data-sortable="" style="width: 20%;"><a href="#" class="dataTable-sorter">查看详情</a></th>
                            </tr>
                            </thead>
                            <tbody>
                            {% for schedule in interview_schedules %}
                            <tr>
                                <td>{{ schedule.id }}</td>
                                <td>{{ schedule.job_posting.title }}</td>
                                <td>{{ schedule.student.stu_name }}</td>
                                <td><span class="badge {% if schedule.status == 'Active' %}bg-success{% else %}bg-danger{% endif %}">{{ schedule.status }}</span></td>
                                <td><a href="{% url 'organization:interview_detail' %}?interview_id={{ schedule.id }}" class="dataTable-sorter"><span class="badge bg-success">详情</span></a></td>
                            </tr>
                            {% endfor %}
                            </tbody>
                        </table>
                    </div>
                    <div class="dataTable-bottom">
                        <div class="dataTable-info">显示 {{ interview_schedules.paginator.count }} 条目中的 {{ interview_schedules.start_index }} 到 {{ interview_schedules.end_index }} 个 </div>
                        <ul class="pagination pagination-primary float-end dataTable-pagination">
                            {% if interview_schedules.has_previous %}
                                <li class="page-item"><a href="?page={{ interview_schedules.previous_page_number }}" class="page-link">‹</a></li>
                            {% endif %}
                            {% for num in interview_schedules.paginator.page_range %}
                                {% if interview_schedules.number == num %}
                                    <li class="page-item active"><a href="#" class="page-link">{{ num }}</a></li>
                                {% else %}
                                    <li class="page-item"><a href="?page={{ num }}" class="page-link">{{ num }}</a></li>
                                {% endif %}
                            {% endfor %}
                            {% if interview_schedules.has_next %}
                                <li class="page-item"><a href="?page={{ interview_schedules.next_page_number }}" class="page-link">›</a></li>
                            {% endif %}
                        </ul>
                    </div>
                </div>
            </div>
        </div>
    </section>

{% endblock %}

{% block show_user %}
    {% if user_label == 1 %}
        {# 当学生用户登录的时候显示学生的姓名和学号 #}
        <div class="card">
            <div class="card-body py-4 px-5">
                <div class="d-flex align-items-center">
                    {# 性别不同默认头像不一样 #}
                    <div class="avatar avatar-xl">
                        {% if gender == 'female' %}
                            <img src="{% static 'picture/5.jpg' %}" alt="Face female">
                        {% else %}
                            <img src="{% static 'picture/2.jpg' %}" alt="Face male">
                        {% endif %}
                    </div>
                    {# 加载学生的姓名和学号 #}
                    <div class="ms-3 name"><h5 class="font-bold">姓名：{{ student.stu_name }}</h5>
                        <h6 class="text-muted mb-0">
                            学号：{{ request.session.user_id }}
                        </h6>
                    </div>
                </div>
            </div>
        </div>
    {% elif user_label == 2 %}
        {# 当企业登录的时候显示组织的名称和账号 #}
        <div class="card">
            <div class="card-body py-4 px-5">
                <div class="d-flex align-items-center">
                    <div class="avatar avatar-xl">
                        <img src="{% static 'picture/5.jpg' %}" alt="Face female">
                    </div>
                    {# 加载企业的姓名和学号 #}
                    <div class="ms-3 name"><h5 class="font-bold">名称：{{ organization.name }}</h5>
                        <h6 class="text-muted mb-0">
                            账号：{{ request.session.user_id }}
                        </h6>
                    </div>
                </div>
            </div>
        </div>
    {% endif %}
{% endblock %}

